#页面：登录页


from selenium.webdriver.common.by import By

from utils.page_base import PageBase

class PageLogin(PageBase):
    pathUrl="/simple/login"
    loc_zanhao=By.NAME,"login_info"
    loc_pwd=By.NAME,"password"
    loc_login=By.XPATH,"//input[@value='登录']"
    loc_errorTips=By.CSS_SELECTOR,"div.prompt"

    def __init__(self,driver,base_url):
        PageBase.__init__(self,driver,base_url)

    #打开本页面的url
    def openUrl(self):
        self.open(PageLogin.pathUrl)

    #输入账号
    def input_zanhao(self,data):
        self.input(PageLogin.loc_zanhao,data)


    #输入密码
    def input_pwd(self,data):
        self.input(PageLogin.loc_pwd,data)

    #点击登录按钮
    def click_login(self):
        self.click(PageLogin.loc_login)

    #判断错误提示标签是否存在
    def isExistsErrorTips(self):
        return self.isExists(PageLogin.loc_errorTips)

    #获取账号框的class属性的值是否有invalid-text
    def isHasZanhaoClass(self):
        attrClass=self.getEleAttr(PageLogin.loc_zanhao,"class")
        if "invalid-text" in attrClass:
            return True
        else:
            return False

    # 获取密码框的class属性的值是否有invalid-text
    def isHasPwdClass(self):
        attrClass = self.getEleAttr(PageLogin.loc_pwd, "class")
        if "invalid-text" in attrClass:
            return True
        else:
            return False

